package com.p2p.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.p2p.model.entity.Account;
import com.p2p.system.common.Result;
import com.p2p.system.service.AccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Date：2023/12/9
 * @Author：lyd
 */
@CrossOrigin
@RestController
@Api(tags = "金额管理模块")
@RequestMapping("/system/account")
public class AccountController {
    @Autowired
    private AccountService accountService;


    @ApiOperation("获取账户金额列表")
    @GetMapping("/{page}/{limit}")
    public Result listAccount(@PathVariable Long page,@PathVariable Long limit){

        IPage<Account> iPage = new Page<>(page,limit);


        iPage = this.accountService.selectPage(iPage);


        return Result.ok(iPage);

    }

    @ApiOperation("获取用户账号金额")
    @PostMapping("/getAccountByIdName/{id}")
    public Result getAccountByIdName(@PathVariable Long id ){
        Account account = this.accountService.selectAccountByIdAndName(id);
        return Result.ok(account);
    }




}
